]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Fix problems on destruction
authorOwen W. Taylor <otaylor@fishsoup.net>
Fri, 26 Feb 2010 17:48:07 +0000 (12:48 -0500)
committerOwen W. Taylor <otaylor@fishsoup.net>
Tue, 2 Mar 2010 21:37:05 +0000 (16:37 -0500)
StScrollBar: Be robust against being disposed multiple times,
  which can happen, and in fact, normally happens when destroying
  the parent.

StScrollView: Implement remove() for the hscroll and vscroll members,
  and just destroy them in dispose() and let them be removed.
  unparent the shadows, instead of just unref'ing them directly.

https://bugzilla.gnome.org/show_bug.cgi?id=611203

src/st/st-scroll-bar.c
src/st/st-scroll-view.c

index 836681c95758879dff3eac4a25bff2c3654f9e01..2698397d4dc34026d1896e9454c942bf8e06e166 100644 (file)
@@ -188,14 +188,23 @@ st_scroll_bar_dispose (GObject *gobject)
       priv->handle = NULL;
     }
 
-  clutter_actor_unparent (priv->bw_stepper);
-  priv->bw_stepper = NULL;
+  if (priv->bw_stepper)
+    {
+      clutter_actor_unparent (priv->bw_stepper);
+      priv->bw_stepper = NULL;
+    }
 
-  clutter_actor_unparent (priv->fw_stepper);
-  priv->fw_stepper = NULL;
+  if (priv->fw_stepper)
+    {
+      clutter_actor_unparent (priv->fw_stepper);
+      priv->fw_stepper = NULL;
+    }
 
-  clutter_actor_unparent (priv->trough);
-  priv->trough = NULL;
+  if (priv->trough)
+    {
+      clutter_actor_unparent (priv->trough);
+      priv->trough = NULL;
+    }
 
   G_OBJECT_CLASS (st_scroll_bar_parent_class)->dispose (gobject);
 }
index 7fef4a023327e135b46bdc90dcb316b1a35471f0..51263fd82c8dedd4b2ed5369f37607c63c6a79bb 100644 (file)
@@ -215,34 +215,29 @@ st_scroll_view_dispose (GObject *object)
 {
   StScrollViewPrivate *priv = ST_SCROLL_VIEW (object)->priv;
 
-  priv->child = NULL;
-
   if (priv->vscroll)
+    clutter_actor_destroy (priv->vscroll);
+
+  if (priv->hscroll)
+    clutter_actor_destroy (priv->hscroll);
+
+  /* since it's impossible to get a handle to these actors, we can
+   * just directly unparent them and not go through destroy/remove */
+  if (priv->top_shadow)
     {
-      clutter_actor_destroy (priv->vscroll);
-      priv->vscroll = NULL;
+      clutter_actor_unparent (priv->top_shadow);
+      priv->top_shadow = NULL;
     }
 
-  if (priv->hscroll)
+  if (priv->bottom_shadow)
     {
-      clutter_actor_destroy (priv->hscroll);
-      priv->hscroll = NULL;
+      clutter_actor_unparent (priv->bottom_shadow);
+      priv->bottom_shadow = NULL;
     }
 
   G_OBJECT_CLASS (st_scroll_view_parent_class)->dispose (object);
 }
 
-static void
-st_scroll_view_finalize (GObject *object)
-{
-  StScrollViewPrivate *priv = ST_SCROLL_VIEW (object)->priv;
-
-  g_object_unref (priv->top_shadow);
-  g_object_unref (priv->bottom_shadow);
-
-  G_OBJECT_CLASS (st_scroll_view_parent_class)->finalize (object);
-}
-
 static void
 st_scroll_view_paint (ClutterActor *actor)
 {
@@ -573,8 +568,7 @@ st_scroll_view_class_init (StScrollViewClass *klass)
 
   object_class->get_property = st_scroll_view_get_property;
   object_class->set_property = st_scroll_view_set_property;
-  object_class->dispose= st_scroll_view_dispose;
-  object_class->finalize = st_scroll_view_finalize;
+  object_class->dispose = st_scroll_view_dispose;
 
   actor_class->paint = st_scroll_view_paint;
   actor_class->pick = st_scroll_view_pick;
@@ -833,6 +827,17 @@ st_scroll_view_remove (ClutterContainer *container,
       g_object_unref (priv->child);
       priv->child = NULL;
     }
+  else
+    {
+      if (actor == priv->vscroll)
+        priv->vscroll = NULL;
+      else if (actor == priv->hscroll)
+        priv->hscroll = NULL;
+      else
+        g_assert ("Unknown child removed from StScrollView");
+
+      clutter_actor_unparent (actor);
+    }
 }
 
 static void